<template>
  <div class="greetings"></div>
  <el-button type="primary" @click="handleRequest">请求</el-button>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import formatTime from '@/utils/formatTime'
import { getUser, getImgs } from '@/api'

const handleRequest = () => {
  getUser()
  getImgs()
}

onMounted(() => {
  handleRequest()
})

// 示例
console.log(formatTime(Date.now(), 'Y-M-D h:m:s')) // 输出当前时间
console.log(formatTime(Date.now(), 'M-D h:m')) // 输出当前时间，不带年和秒
console.log(formatTime(Date.now(), 'Y-M-D h:m:s', { week: true })) // 输出当前时间和星期数
console.log(formatTime(Date.now() - 1000 * 60 * 5, 'Y-M-D h:m:s', { client: true })) // 输出1分钟前
console.log(formatTime(Date.now() - 1000 * 60 * 35, 'Y-M-D h:m:s', { client: true })) // 输出30分钟前
console.log(formatTime(Date.now() - 1000 * 60 * 65, 'Y-M-D h:m:s', { client: true })) // 输出1个小时前
console.log(formatTime(Date.now() - 1000 * 60 * 95, 'Y-M-D h:m', { client: true })) // 输出时间，不带秒
</script>

<style scoped></style>
